let arr = [1, 2, 3, [4, 5]];
console.log(arr.flat());
/**结果
[ 1, 2, 3, 4, 5 ]
 */
console.log(arr);
/**结果
[ 1, 2, 3, [ 4, 5 ] ]
*/

let arr1 = [1, 2, 3, [4, [5]], [[[[6]]]]];
console.log(arr1.flat(2));
/**结果
[ 1, 2, 3, 4, 5, [[6]] ]
*/
console.log(arr1.flat(Infinity));
/**结果
[ 1, 2, 3, 4, 5, 6 ]
*/
